package cn.zch.test.imgocr;
import cn.zch.util.constant.ConBaiDuApi;
import com.baidu.aip.imageclassify.AipImageClassify;
import org.json.JSONObject;

import java.util.HashMap;
public class ImgOcr {
	public static void plantDetect(String imagePath) {
		// 初始化一个AipImageClassifyClient
		AipImageClassify client = new AipImageClassify(ConBaiDuApi.IMG_OCR_APP_ID, ConBaiDuApi.IMG_OCR_API_KEY, ConBaiDuApi.IMG_OCR_SECRET_KEY);
		// 传入可选参数调用接口
		HashMap<String, String> options = new HashMap<>();
		// options.put("baike_num", "5");
		// 参数为本地路径
		System.setProperty("aip.log4j.conf", "properties/log4j.properties");
		// String image = "E:\\a.jpg";
		JSONObject res = client.plantDetect(imagePath, options);
		System.out.println(res.toString(2));
		// 参数为二进制数组
		//		byte[] file = readFile("test.jpg");
		//		res = client.plantDetect(file, options);
		//		System.out.println(res.toString(2));
	}
}
